import 'package:flutter/material.dart';

class DkDivider extends StatelessWidget {
  final DividerOption dividerOption;

  DkDivider(this.dividerOption) : super(key: dividerOption.key);

  @override
  Widget build(BuildContext context) {
    bool isHorizontal = dividerOption.dividerType == DividerType.horizontal;
    return Container(
      height: isHorizontal ? dividerOption.height : null,
      width: isHorizontal ? null : dividerOption.width,
      color: dividerOption.color,
      margin: isHorizontal
          ? EdgeInsetsDirectional.only(
              start: dividerOption.indentStart, end: dividerOption.indentEnd)
          : EdgeInsetsDirectional.only(
              top: dividerOption.indentStart, bottom: dividerOption.indentEnd),
    );
/*
    return SizedBox(
      height: isHorizontal ? dividerOption.height : null,
      width: isHorizontal ? null : dividerOption.width,
      child: Center(
        child: Container(
          height: isHorizontal ? 0.0 : null,
          width: isHorizontal ? null : 0.0,
          margin: EdgeInsetsDirectional.only(
              start: dividerOption.indentStart, end: dividerOption.indentEnd),
          decoration: BoxDecoration(
            border: Border(
              bottom: isHorizontal
                  ? Divider.createBorderSide(context,
                      color: dividerOption.color)
                  : BorderSide.none,
              left: isHorizontal
                  ? BorderSide.none
                  : Divider.createBorderSide(context,
                      color: dividerOption.color),
            ),
          ),
        ),
      ),
    );
*/
  }
}

enum DividerType { horizontal, vertical }

class DividerOption {
  Key key;
  double width;
  double height;
  double indentStart;
  double indentEnd;
  Color color;
  DividerType dividerType;

  DividerOption(
      {this.key,
      this.width,
      this.height,
      this.indentStart,
      this.indentEnd,
      this.color,
      this.dividerType}) {
    if (null == dividerType) {
      dividerType = DividerType.horizontal;
    }
    if (dividerType == DividerType.horizontal) {
      height ??= 0.5;
      width = 0.0;
    }
    if (dividerType == DividerType.vertical) {
      width ??= 0.5;
      height = 0.0;
    }
    color ??= Color(0xffEBEEEF);
    indentStart ??= 0.0;
    indentEnd ??= 0.0;
  }

  DividerOption.horizontal(
      {this.key, this.height, this.indentStart, this.indentEnd, this.color}) {
    height ??= 0.5;
    width = 0.0;
    indentStart ??= 0.0;
    indentEnd ??= 0.0;
    color ??= Color(0xffEBEEEF);
    dividerType = DividerType.horizontal;
  }

  DividerOption.vertical(
      {this.key, this.width, this.indentStart, this.indentEnd, this.color}) {
    width ??= 0.5;
    height = 0.0;
    indentStart ??= 0.0;
    indentEnd ??= 0.0;
    color ??= Color(0xffEBEEEF);
    dividerType = DividerType.vertical;
  }
}
